/*
 * @Descripttion: 老师接口
 * @version: 
 * @Author: hzx
 * @Date: 2021-03-03 00:16:02
 * @LastEditors: hzx
 * @LastEditTime: 2021-03-06 22:02:35
 */

import { get, post } from "@/utils/request";


/**
 * @name: 查询所有老师信息
 * @msg: 
 * @param {*}
 * @return {*}
 */
export async function getTeachers(){
    let [response, error] = await get(`/teacher/getTeachers`);
    return response !== null ? response : error
}

/**
 * @name: 根据老师编号查询老师信息
 * @msg:  
 * @param {*} t_id
 * @return {*}
 */
 export async function selectTeacherId(t_id){
    let [response, error] = await get(`/teacher/selectTeacherId/${t_id}`);
    return response !== null ? response : error
}

/**
 * @name:  根据班级编号查询班级老师信息
 * @msg:   
 * @param {*} class_id
 * @return {*}
 */
export async function selectClassId(class_id){
    let [response, erroor] = await get(`teacher/selectClassId/${class_id}`);
    return response !== null ? response : error
}

/**
 * @name: 添加一个老师
 * @msg: 增加成功
 * @param {*} {t_id, dev_id, t_sex, rx_time, t_name}
 * @return {*}
 */
export async function insterTeacher(teacher){
    //console.log(teacher)
    let [response, error] = await post(`/teacher/insterTeacher`,{...teacher});
    return response !== null ? response : error
}

/**
 * @name: 
 * @msg: 
 * @param {*}
 * @return {*}
 */

 export async function updateTeacher(teacher){
    //console.log(teacher)
    let [response, error] = await post(`/teacher/updateTeacher`,{...teacher});
    return response !== null ? response : error
}

/**
 * @name: 删除一个老师
 * @msg:  删除成功
 * @param {*} t_id
 * @return {*}
 */
export async function delTeacher(t_id){
    let [response, error] = await get(`/teacher/delTeacher/${t_id}`);
    return response !== null ? response : error
}

/**
 * @name: 根据部门名称查询老师信息
 * @msg: 
 * @param {*} 部门名称
 * @return {*}
 */
export async function selectDevname(dev_name){
    let [response, error] = await get(`/teacher/selectDevname?dev_name=${dev_name}`);
    return response !== null ? response : error
}